package com.hua.api.modules.pay.dao;

import com.hua.api.core.framework.statement.EntityManagerTemplate;
import com.hua.api.core.framework.statement.Statement;
import com.hua.api.core.framework.statement.mysql.StatementFactoryImpl;
import com.hua.api.modules.pay.domain.OrderInfoPayinfo;
import org.springframework.stereotype.Repository;

@Repository
public class OrderInfoPayinfoDao  extends EntityManagerTemplate {


    public OrderInfoPayinfo findOrderInfoPayinfoUseOrderOutTradeNo(String outTradeNo){
        Statement statement = StatementFactoryImpl.getInstance().createStatement("from OrderInfoPayinfo o where o.outTradeNo=?1");
        statement.addParams(outTradeNo);
        return findObject(statement,OrderInfoPayinfo.class);

    }

    public OrderInfoPayinfo fineOrderInfoPayinfoUseRefundNo(String refundNo){
        Statement statement = StatementFactoryImpl.getInstance().createStatement("from OrderInfoPayinfo p where p.outRefundNo=?1");
        statement.addParam(refundNo);
        return findObject(statement,OrderInfoPayinfo.class);
    }

    public OrderInfoPayinfo findOrderInfoPayinfo(String orderNo,String state){
        Statement statement = StatementFactoryImpl.getInstance().createStatement("from OrderInfoPayinfo p where p.orderNo=?1 and p.state=?2");
        statement.addParams(orderNo,state);
        return findObject(statement,OrderInfoPayinfo.class);
    }

    public OrderInfoPayinfo findOrderInfoPayinfo(String outTradeNo){
        Statement statement = StatementFactoryImpl.getInstance().createStatement("from OrderInfoPayinfo p where p.outTradeNo=?1");
        statement.addParam(outTradeNo);
        return findObject(statement,OrderInfoPayinfo.class);
    }




}
